home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / headers / spincursor.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  3.2 KB  |  108 lines

  1. /*
  2.     File:        SpinCursor.h
  3.  
  4.     Contains:    TSpinCursor is a simple cursor spinning class.
  5.                   SpinCursor.h contains the TSpinCursor class definition.
  6.  
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. // Declare label for this header file
  25. #ifndef _SPINCURSOR_
  26. #define _SPINCURSOR_
  27.  
  28. #ifndef _DTSCPLUSLIBRARY_
  29. #include "DTSCPlusLibrary.h"
  30. #endif
  31.  
  32.  
  33. // TOOLBOX INTERFACES
  34. #ifndef __QUICKDRAW__
  35. #include <Quickdraw.h>
  36. #endif
  37.  
  38. #ifndef __RESOURCES__
  39. #include <Resources.h>
  40. #endif
  41.  
  42. #ifndef __MEMORY__
  43. #include <Memory.h>
  44. #endif
  45.  
  46. #ifndef __TOOLUTILS__
  47. #include <ToolUtils.h>
  48. #endif
  49.  
  50.  
  51. // _________________________________________________________________________________________________________ //
  52. //    TSpinCursor Class Interface.
  53.  
  54. class TSpinCursor
  55. // TSpinCursor is a simple cursor spinning/controlling class, that will bind the CURS and 'acur' resources
  56. // specified, and animate the cursor to either direction based on the 'acur' list.
  57. {
  58. public:
  59.     // ENUMS AND TYPEDEFS
  60.     enum EDirection                                // our cursor spinning direction
  61.     {
  62.         kBackwards = -1, kForwards = 1
  63.     };
  64.  
  65.     // CONSTRUCTORS AND DESTRUCTORS
  66.     TSpinCursor(short acurID,                    // the 'acur' resource used
  67.                 short SpinDirection = kForwards,// spindirection (default forwards)
  68.                 short spinTicks = 60);            // amount of ticks between spins (1 second default)
  69.     virtual~ TSpinCursor();
  70.  
  71.     // MAIN INTERFACE
  72.     virtual void Spin();                        // start spinning
  73.     virtual void SetSpinDirection(EDirection);    // change directions    
  74.     // INTERNAL STRUCTS
  75.     struct AnimationCursRec                        // structure needed to map the 'acur' resource to a data structure
  76.     {
  77.         struct
  78.         {
  79.             unsigned short hasColor:1;            // if true uses color cursors
  80.             unsigned short count:15;            // # of frames in the cursor list
  81.         } information;
  82.         short frame;                            // cursor index list of next cursor frame
  83.         CursHandle nCursors[20];                // list of cursor handles
  84.     };
  85.  
  86.     // FIELDS
  87. protected:CursHandle fCursorHandle;                // reference to our cursor handle
  88.     short fCursorID;                            // ID of the CURS resource
  89.     short fIndex;                                // index to the animated cursor list
  90.     short fSpinDirection;                        // 1 = forward, -1 backwards, 2 skip every 2 frames…
  91.     AnimationCursRec * *fCursorList;            // list of cursors we will use
  92.     long fTickCounter;                            // our Tick counter
  93.     short fSpinTicks;                            // amount of ticks between spins
  94.     OSErr fError;                                // latest error
  95. };
  96.  
  97.  
  98. #endif
  99.  
  100. // _________________________________________________________________________________________________________ //
  101.  
  102.  
  103. /*    Change History (most recent last):
  104.   No        Init.    Date        Comment
  105.   1            khs        12/14/92    New file
  106.   2            khs        1/3/93        Cleanup
  107. */
  108.